<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<html>
<c:set var="pageTitle" value="设计员占比" />
<%@ include file="../inc/Title.jsp"%>
<head>
<script src="/js/minierp.js"></script>
<script language="javascript">
	function doOk(){
		var len=${fn:length(idList)};
		var idStr="";
		var nameStr="";
		var total=0;
		for(i=0;i<len;i++){
			var rate=document.getElementById("rate_"+i).value.trim();
			if(rate!=null && rate!=""){
				if(isNaN(rate)){
					alert("占比只能输入数字");
					return;
				}else if((rate-0)<=0 || (rate-0)>1){
					alert("占比只能输入大于0且小于等于1的数字");
					return;
				}else{
					total=addMul(total,rate);
				}
				if(idStr!=""){
					idStr=idStr+";";
					nameStr=nameStr+";";
				}
				idStr=idStr+document.getElementById("id_"+i).value+":"+rate;
				nameStr=nameStr+document.getElementById("name_"+i).value+" "+rate;
			}
		}
		if(total>1){
			alert("占比总和不能超过1，请修正");
			if(document.getElementById("rate_0")!=null){
				document.getElementById("rate_0").focus();
			}
			return;
		}
		if(idStr!=""){
			var a=new Array();
			a[0]=idStr;
			a[1]=nameStr;
			window.parent.returnValue=a;
		}
		window.parent.close();
	}
	function doCancel(){
		window.parent.close();
	}
	function showMe(){
		if(document.getElementById("rate_0")!=null){
			document.getElementById("rate_0").focus();
		}
		if(checkNavigator()[0]=="safari"){
			document.getElementById("bodyDiv").style.width=document.getElementById("bodyDiv").offsetWidth-40;
		}
		showFormErrorMsg();
	
		var normalHeiht=245;
		var alertHeight=normalHeiht+40;
		if(document.getElementById("errorMsgTr")!=null && document.getElementById("errorMsgTr").style.display==""){
			window.dialogHeight=alertHeight+"px";
		}else{
			window.dialogHeight=normalHeiht+"px";
		}
	}
	function checkInput(index){
		if(window.event.keyCode==13){
			var ind=index-0+1;
			if(document.getElementById("rate_"+ind)!=null){
				document.getElementById("rate_"+ind).focus();
			}else{
				doOk();
			}
		}
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onLoad="showMe();" class="sheet modal-dialog" style=" padding-top:15px;">
<div class="sheet-main" id="bodyDiv" style="width:295px;">
	<form name="frm" method="post">
	  <div class="sheet-list" style="width:100%">
	    <div class="modal-main search-business"  style="width:100%">
				<c:set var="pageTopTitle" value="设计员占比" />
				<%@ include file="../inc/PageTop.jsp"%> 
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-a">
					<c:forEach var="item" items="${nameList}" varStatus="i">
					<tr>
				      	<th style="width:40%">${item}：</th>
				      	<td style="width:60%">
				      		<input type="text" class="f-text" size="10" maxlength="4" id="rate_${i.index}" name="rate_${i.index}" value="${defVal}" onKeyUp="checkInput(${i.index});">
				      		<input type="hidden" id="id_${i.index}" name="id_${i.index}" value="${idList[i.index]}">
				      		<input type="hidden" id="name_${i.index}" name="name_${i.index}" value="${item}">
				     	</td>
					</tr>
					</c:forEach>
					<tr>
						<th colspan="2" class="give"><div align="left"><br>1表示全部由本人完成，0.5表示本人完成一半，<br>以此类推。</div></th>
					</tr>
				</table>		
	  	</div>
	  </div>
		<div class="modal-buttom" id="buttonDiv">
			<input type="button" class="buttom-a" value="确 定" onClick="doOk();">
			<input type="button" class="buttom-a" value="取 消" onClick="doCancel();">
		</div>
	</form>
</div>		
</body>
</html>